<template>
  <div class="echart-part">
    <echart-title :title="para.title"></echart-title>
    <div class="myechart_content" ref="tablefather">
      <Table :height="tableHeight" :columns="columns" :data="data" :row-class-name="rowClassName"></Table>
    </div>
  </div>
</template>

<script>

  import echartTitle from "../common/echart-title";
  import {data} from "./data";

  export default {
    name: 'state-data-table',
    props: {
      para: {}
    },
    components: {
      echartTitle
    },
    data() {
      return {
        timer: "",
        columns: [
        ],
        data: [
        ],
        tableHeight:200
      }
    },
    mounted() {
      this.getData()
      this.tableHeight=this.$refs.tablefather.offsetHeight-30

    },
    watch: {

    },
    beforeDestroy() {
      if (this.timer) { //如果定时器还在运行 或者直接关闭，不用判断
        clearInterval(this.timer); //关闭
      }
    },

    methods: {
      getData(){
        this.data=[
          {
            name: 'John Brown',
            age: 18,
            address: 'New York No. 1 Lake Park',
            date: '2016-10-03'
          },
          {
            name: 'Jim Green',
            age: 24,
            address: 'London No. 1 Lake Park',
            date: '2016-10-01'
          },
          {
            name: 'Joe Black',
            age: 30,
            address: 'Sydney No. 1 Lake Park',
            date: '2016-10-02'
          },
          {
            name: 'Jon Snow',
            age: 26,
            address: 'Ottawa No. 2 Lake Park',
            date: '2016-10-04'
          }
        ]
        this.columns= [
          {
            title: 'Name',
            key: 'name'
          },
          {
            title: 'Age',
            key: 'age'
          },
          {
            title: 'Address',
            key: 'address'
          }
        ]
      },
      rowClassName(row, index) {
        if (index % 2 == 0) {
          return "demo-table-error-row"
        } else if(index % 2 == 1){
          return "demo-table-info-row"
        }
      }
    }
  }
</script>

<style scoped>
  .mybackground {
    background: rgba(17, 35, 60, 0.50);
    border-radius: 10px;
  }

  .myflex {
    display: flex;
    justify-content: space-around;
  }

  .myimg {
    height: 154px;
  }

  .myfont {
    font-family: PingFangSC-Medium;
    font-size: 14px;
    color: #008AD9;
    line-height: 20px;
    font-weight: 500;
  }

  .myfont2 {
    font-family: PingFangSC-Regular;
    font-size: 12px;
    color: #58BFF9;
    line-height: 12px;
    font-weight: 400;
  }

  .myposition {
    width: 100px;
    position: absolute;
    left: 50%;
    margin-left: -50px;
  }

  .myechart_content {
    padding: 15px 25px;
    background: rgba(17, 35, 60, 0.50);
    border-radius: 10px;
    width: 98%;
    height: 100%;
  }
  /deep/ .ivu-table .demo-table-info-row td {
    background-color: #162b41;
    color: #85ABC5;
    border: none;
    font-size: 0.75rem;
  }
  /deep/ .ivu-table .demo-table-info-row td:first-child {
    border-radius: 5px 0 0 5px;
  }
  /deep/ .ivu-table .demo-table-info-row td:last-child {
    border-radius: 0 5px 5px 0;
  }
  /deep/ .ivu-table .demo-table-error-row td{
    color: #85ABC5;
    border: none;
    font-size: 0.75rem;
  }
  /deep/ .ivu-table-body table{
    width: 100%!important;
  }
  /deep/ .ivu-table{
    background-color: rgba(0,0,0,0);
  }
  /deep/ .ivu-table:before, .ivu-table:after{
    background-color: rgba(0,0,0,0);
  }
  /deep/ .ivu-table-header th{
    color: #00AEFF;
    background-color: #162b41;
    border: none;
    font-size: 0.75rem;
    font-weight: 400;
  }
  /deep/ .ivu-table-header th .ivu-table-cell{
    white-space: nowrap;
  }
  /deep/ .ivu-table-header th:first-child{
    border-radius: 5px 0 0 5px;
  }
  /deep/ .ivu-table-header th:last-child{
    border-radius: 0 5px 5px 0;
  }
  /deep/ .ivu-table td, .ivu-table th{
    background-color: rgba(0,0,0,0);
    height: 31px;
  }

  /deep/::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background-color: #041c34;
  }
  /deep/::-webkit-scrollbar-track {
    border-radius: 10px;
  }
  /deep/::-webkit-scrollbar-thumb {
    background-color: #007acc;
  }

</style>

